package com.weijianhuawen.wjblog.web.controller;

import com.weijianhuawen.wjblog.common.aspect.ApiOperationLog;
import com.weijianhuawen.wjblog.common.utils.PageResponse;
import com.weijianhuawen.wjblog.common.utils.Response;
import com.weijianhuawen.wjblog.web.mode.vo.category.FindCategoryArticlePageListReqVo;
import com.weijianhuawen.wjblog.web.mode.vo.category.FindCategoryListReqVo;
import com.weijianhuawen.wjblog.web.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-10-28 22:48
 */

@RestController
@RequestMapping("/category")
@Api(tags = "分类模块")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;
    @PostMapping("/list")
    @ApiOperation(value = "获取所有分类列表")
    @ApiOperationLog(description = "获取所有分类列表")
    public Response findCategoryList(@RequestBody @Validated FindCategoryListReqVo vo) {
        return categoryService.findCategoryList(vo);
    }

    @PostMapping("/article/list")
    @ApiOperation(value = "根据分类id 获取对应文章分页列表")
    @ApiOperationLog(description = "根据分类id 获取所关联的文章列表")
    public PageResponse findCategoryArticlePageList(@RequestBody @Validated FindCategoryArticlePageListReqVo vo) {
        return categoryService.findCategoryArticlePageList(vo);
    }
}
